// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
// This source file is part of the Cangjie project, licensed under Apache-2.0
// with Runtime Library Exception.
//
// See https://cangjie-lang.cn/pages/LICENSE for license information.

#ifndef CANGJIE_MIGRATOR_CANGJIETOOLS_CJPM
#define CANGJIE_MIGRATOR_CANGJIETOOLS_CJPM

#include "Platform/EnvironmentVariable.h"

#include "Path.h"

#include "PackageCompileInfo.h"
#include "Deveco/CjpmRunParameter.h"

namespace CangjieMigrator::CangjieTools {

class Cjpm {
public:
    class RunParameter {
    public:
        std::string command;
        std::vector<Platform::EnvironmentVariable> environment;

        explicit RunParameter(std::string command, std::vector<Platform::EnvironmentVariable> environment);
        explicit RunParameter(const Deveco::CjpmRunParameter &runParameter);
        explicit RunParameter(const Deveco::CjpmRunParameter &&runParameter);

        static RunParameter GenerateDefault(const Path &cangjieHome);
    };

    RunParameter parameter;

    explicit Cjpm(const Path &cangjieHome);
    explicit Cjpm(RunParameter parameter);
    explicit Cjpm(const Deveco::CjpmRunParameter &parameter);

    [[nodiscard]] std::unique_ptr<std::vector<std::string>> Run(const Path &projectPath, const Path &targetDir) const;
    [[nodiscard]] std::vector<PackageCompileInfo> Build(const Path &projectPath, const Path &targetDir) const;
};

} // namespace CangjieMigrator::CangjieTools

#endif // CANGJIE_MIGRATOR_CANGJIETOOLS_CJPM